package com.yc.damai.util;

import com.yc.damai.biz.BizException;

import java.util.Collection;
import java.util.Map;

public class Utils {

    public boolean isEmpty(Object value){
        if(value == null){
            return true;
        } else if(value instanceof String){
            return ((String)value).isBlank();
        } else if(value instanceof Collection){
            return ((Collection)value).isEmpty();
        } else if(value instanceof Map){
            return ((Map)value).isEmpty();
        } else {
            return false;
        }
    }

    public void check(boolean result, String msg) throws BizException {
        if(result){
            throw new BizException(msg, null);
        }
    }
}
